package com.complex.spring.mvc.controller;

import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import com.complex.spring.mvc.service.LoginService;

/**
 * 实现Controller接口 的controller
 * @author gao
 *
 */
public class LoginController implements Controller{
	
	static final Log logger = LogFactory.getLog(LoginController.class);
	
	//@Autowired
	LoginService loginService;
	
	String viewName;
	
	@Override
	public ModelAndView handleRequest(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		//输出log信息
		if(logger.isInfoEnabled()){
			logger.info("=======================LoginController handleRequest=======================");
		}
		//处理业务逻辑
		//loginService.doLogin();
		
		//设置返回数据
		HashMap<String,String> param = new HashMap<String,String>();
		param.put("loginId", "ymkyve");		
		
		//返回到login.jsp
		return new ModelAndView(viewName,param);
	}

	public LoginService getLoginService() {
		return loginService;
	}

	public void setLoginService(LoginService loginService) {
		this.loginService = loginService;
	}

	public String getViewName() {
		return viewName;
	}

	public void setViewName(String viewName) {
		this.viewName = viewName;
	}

}
